home *** CD-ROM | disk | FTP | other *** search
-
- //
- // Description:
- // Tool Bar example demonstrating now to derive new toolbar classes from
- // 'toolbar.js' base class. Defines new class called myVslTools.
- //
- // Super class:
- // myclasses/toolbars/toolbar.js
- //
- // Constructor:
- // toolbar = new myVslTools(Integer Orientation);
- //
- // Attributes:
- // --
- //
- // Methods:
- // --
- //
-
- include("myclasses/toolbars/mytoolbar.js"); // our super class
- include("real/layer/r3matlay.js"); // material layer
- include("real/code/r3vsl.js"); // vsl material
- include("real/code/r3mpphas.js"); // vsl shader
- include("real/code/r3mptext.js"); // vsl texture map
- include("real/code/r3mpnois.js"); // vsl noise
- include("real/code/r3mpcurv.js"); // vsl curve
- include("real/code/r3curve.js"); // curve object
- include("real/code/r3mpvar.js") // variable
- include("real/code/r3mpif.js"); // if
-
- function myVsl(button, event, value)
- {
- vsl = new r3Vsl(R3RA_Name, "my VSL");
- if(vsl) {
- button.layer.LOCKEXCLUSIVE(0);
- button.layer.INSERT(0, 0, vsl);
- button.layer.RELEASE(0);
- }
- }
-
- // create texture map VSL material
-
- function myTextureMap(button, event, value)
- {
- vsl = new r3Vsl(0);
- vsl.SetName("texture map");
- if(vsl) {
- shader = new r3Mpphaselevel(0);
- if(shader) {
- shader.SetPhase(R3CLID_PHASESURFACE);
- vsl.INSERTPROP(0, 0, shader);
- texture = new r3Mptexture(0);
- if(texture) {
- texture.SetParent(shader);
- texture.SetImageName("textures/lake.ppm");
- texture.SetTileX(TRUE);
- texture.SetTileY(TRUE);
- }
- }
- button.layer.LOCKEXCLUSIVE(0);
- button.layer.INSERT(0, 0, vsl);
- button.layer.RELEASE(0);
- }
- }
-
-
- // Create reflection map material
-
- function myReflectionMap(button, event, value)
- {
- vsl = new r3Vsl(0);
- vsl.SetName("reflection map");
-
- if(vsl) {
- shader = new r3Mpphaselevel(0);
-
- if(shader) {
- shader.SetPhase(R3CLID_PHASESURFACE);
- vsl.INSERTPROP(0, 0, shader);
- texture = new r3Mptexture(0);
- if(texture) {
- texture.SetParent(shader);
- texture.SetImageName("textures/lake.ppm");
- texture.SetOutputChannel(R3CLID_REFLECTIONCHANNEL);
- texture.SetOutputName("Reflection");
- }
- }
- button.layer.LOCKEXCLUSIVE(0);
- button.layer.INSERT(0, 0, vsl);
- button.layer.RELEASE(0);
- }
- }
-
-
- // create noise material
-
- function myNoise(button, event, value)
- {
- vsl = new r3Vsl(0);
- if(vsl) {
- vsl.SetName("noise");
- shader = new r3Mpphaselevel(0);
- if(shader) {
- shader.SetPhase(R3CLID_PHASESURFACE);
- vsl.INSERTPROP(0, 0, shader);
-
- noise = new r3Mpnoise(0);
- if(noise) {
- noise.SetParent(shader);
- noise.SetDimensions(3.0);
- noise.SetOctaves(4);
- noise.SetAmplitude(0.5);
- noise.SetBase(0.5);
- noise.SetSmooth(TRUE);
- }
- }
- button.layer.LOCKEXCLUSIVE(0);
- button.layer.INSERT(0, 0, vsl);
- button.layer.RELEASE(0);
- }
- }
-
- // create a curve vsl object to define reflection
-
- function myCurve(button, event, value)
- {
- vsl = new r3Vsl(0);
- if(vsl) {
- vsl.SetName("curve");
- shader = new r3Mpphaselevel(0);
- if(shader) {
- shader.SetPhase(R3CLID_PHASESURFACE);
- vsl.INSERTPROP(0, 0, shader);
-
- mpcurve = new r3Mpcurve(0);
- if(mpcurve) {
- mpcurve.SetParent(shader);
-
- // attach to reflection channel
- mpcurve.SetOutputChannel(R3CLID_REFLECTIONCHANNEL);
- mpcurve.SetOutputName("Reflection");
-
- // fetch the actual curve object and insert a point to it
- curve = mpcurve.GetCurve();
- if(curve) {
- curve.ADDPOINTIFNOTONLINE(R3TID_VECTOR, new r3Vect(0.5, 0.5, 0.5), new r3Vect(0.3, 0.2, 0.1));
- }
- }
- }
- button.layer.LOCKEXCLUSIVE(0);
- button.layer.INSERT(0, 0, vsl);
- button.layer.RELEASE(0);
- }
- }
-
-
- function myIf(button, event, value)
- {
- vsl = new r3Vsl(0);
- if(vsl) {
- vsl.SetName("If");
- shader = new r3Mpphaselevel(0);
- if(shader) {
- shader.SetPhase(R3CLID_PHASESURFACE);
- vsl.INSERTPROP(0, 0, shader);
-
- mpif = new r3Mpif(0);
- if(mpif) {
- mpif.SetParent(shader);
- mpif.SetType(R3MPTYPE_IF);
-
- mpif.SetCondition1(R3MPIFSTATE_TEST);
- mpif.SetMin1(0.3);
- mpif.SetMax1(0.7);
-
- mpif.SetCondition2(R3MPIFSTATE_TEST);
- mpif.SetMin2(0.15);
- mpif.SetMax2(0.85);
-
- mpif.SetCondition3(R3MPIFSTATE_OFF);
- mpif.SetMin3(0);
- mpif.SetMax3(0);
- }
- }
- button.layer.LOCKEXCLUSIVE(0);
- button.layer.INSERT(0, 0, vsl);
- button.layer.RELEASE(0);
- }
- }
-
-
- function myVslTools(orientation)
- {
- if(arguments.length == 0)
- return;
-
- // initialize interface to material layer
- matLayer = new r3Materiallayer();
- matLayer.r3Attach(Get("CurrentProject.Materials"));
-
- // call the super class constructor
- this.base = myToolBar;
- this.base("VSL Tools", orientation, matLayer);
-
- // add tool buttons
- this.AddTool("Material", myVsl);
- this.AddTool("Texture", myTextureMap);
- this.AddTool("Noise", myNoise);
- this.AddTool("Reflection", myReflectionMap);
- this.AddTool("Curve", myCurve);
- this.AddTool("IF", myIf);
- }
-
- myVslTools.prototype=new myToolBar;
-